<template>
    <a-modal v-model="visible" title="登录" @ok="handleOk">
        <p style="display:flex;justify-content:center;align-items:center">
            账号： <input v-model="userPhone" placeholder="请输入手机号"/>
        </p>
        <p style="display:flex;justify-content:center;align-items:center">
          密码：  <input v-model="userPassWord" placeholder="请输入密码" type="password"/>
        </p>

    </a-modal>
</template>
<script>
import { userLogin } from '@/api/user';
export default {
    name:'popModal',
    data() {
        return {
            userPhone:'',
            userPassWord:'',
            visible:false,
        }
    },
    mounted() {
            
        this.userPassWord='';
        this.userPhone='';
    },
    methods:{
        open(){ 
            //console.log("调用打开了");
            this.visible=true;
        },
        handleOk() {
            let params = {
                Name:this.userPhone,
                PassWord:this.userPassWord
            }
            userLogin(params).then((res)=>{
                //console.log(res)
                if(res.Code==200){
                    
                    localStorage.setItem('userToken',res.Data.AccessToken);
                    this.$emit('onLoginSuccess')
                    this.$message.success('登录成功')
                    this.visible=false;
                }else{
                    this.$message.error('账号或密码错误')
                }
            }).catch(e=>{
                //console.log(e);
            })

            
            // this.$emit('visibleStatus', false)
        }
    }
}

</script>
<style scoped>
</style>